local zhiti = fk.CreateSkill {

  name = "joy__zhiti",

  tags = { Skill.Compulsory, },

}



zhiti:addEffect(fk.DrawNCards, {
  name = "joy__zhiti",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = {fk.DrawNCards},
  can_trigger = function(self,event,target,player,data)
    return target == player and player:hasSkill(zhiti.name)
    and #table.filter(player.room.alive_players, function(p) return p:isWounded() end) > 1
  end,
  on_use = function(self, event, target, player, data)
    data.n = data.n + 1
  end,
})

zhiti:addEffect("targetmod", {
  name = "#joy__zhiti_targetmod",
  residue_func = function(self, player, skill, scope)
    if skill.trueName == "slash_skill" and player:hasSkill(zhiti.name) then
      local n = 0
      for _, p in ipairs(Fk:currentRoom().alive_players) do
        if p:isWounded() then
          n = n + 1
        end
      end
      if n > 2 then
        return 1
      end
    end
  end,
})

return zhiti